import 'dart:async';
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:path_provider/path_provider.dart';

class RecordProvider with ChangeNotifier {
  bool _isRecord = false;
  String recorderText = '00:00:00';

  get isRecord => _isRecord;

  get recorderTxt => recorderText;




  void startRecord() {
    _isRecord = true;

    notifyListeners();
  }

  void stopRecord() {
    _isRecord = false;
    notifyListeners();
  }

  void recordTimeListen(String recorderTxt) {
    print('www$recorderText');
    this.recorderText=recorderTxt;
    notifyListeners();
  }

  // void startRecorder() async {
  //   try {
  //     Directory appDocDir = await getApplicationDocumentsDirectory();
  //     String filePath = appDocDir.path + "/";
  //     print("filePath===$filePath");
  //     String path = await flutterSound.startRecorder(
  //         uri: "$filePath${currentTimeMillis()}.aac");
  //     print('startRecorder: $path');
  //     _recorderSubscription = flutterSound.onRecorderStateChanged.listen((e) {
  //       DateTime date =
  //           new DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
  //       String txt = DateFormat('mm:ss:SS', 'en_US').format(date);
  //       this.setState(() {
  //         this._recorderTxt = txt.substring(0, 8);
  //       });
  //     });
  //
  //     this.setState(() {
  //       this._isRecording = true;
  //     });
  //   } catch (err) {
  //     print('startRecorder error: $err');
  //   }
  // }
}
